import { View } from '@tarojs/components'
import React from 'react'
import { XmImage } from '@/components/tool'
import addImg from "@/static/images/add.png";
import delImg from "@/static/images/del.png";
import './index.scss'

function Index(props: { value: number, onChange: (e: "add" | "del") => void, min?: number, max?: number }) {
  const _num = props.value || 0
  const _max = props.max || 100
  const _min = props.min || 0
  return (
    <View className="flex ped-box s-lg c-black f-weight-bold">
      <XmImage src={delImg} size={42} onClick={() => _num > _min && props.onChange("del")}></XmImage>
      <View className="num-txt t-center">{_num}</View>
      <XmImage src={addImg} size={42} onClick={() => _num < _max && props.onChange("add")}></XmImage>
    </View>
  )
}
export default React.memo(Index)

